import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-02-27
 * Time: 9:06
 */
public class Test {
    public static void main1(String[] args) {
        Map<String,Integer> treeMap = new TreeMap<>();
        //key一定是可以比较的
        treeMap.put("hello",3);
        treeMap.put("abc",8);
        treeMap.put("the",4);
        System.out.println(treeMap);
        Integer val = treeMap.getOrDefault("hello2",100);
        System.out.println(val);
        //获取不重复key所有的值
        Set<String> keySet = treeMap.keySet();
        System.out.println(keySet);
        Collection<Integer> values = treeMap.values();
        System.out.println(values);

        Set<Map.Entry<String,Integer>> set = treeMap.entrySet();
        for (Map.Entry<String,Integer> entry: set) {
            System.out.println("key:"+entry.getKey()+" "+"value:"+entry.getValue());
        }
    }

    public static void main(String[] args) {
        Set<String> set1 = new TreeSet<>();
        set1.add("hello");
        set1.add("abc");
        set1.add("abc");
        //不能添加重复值，且重要的特点就是去重
        System.out.println(set1);
    }


}
